function judgeScrollBar(id) {
    var ulMulti = $("#" + id).next().find("ul");
    var num = ulMulti.find("li").length;
    if (num > 9) {
        ulMulti.css("overflow", "auto");
    } else {
        ulMulti.css("overflow", "hidden");
    }
}

/**
 *
 */
function isNull(obj) {
    return ((typeof(obj) == 'undefined') || (obj == null) || (obj.length == 0));
}

//没有图片
function nofindImg(img) {
    img.src = "/templates/img/add.jpg";
    //img.onerror = null;
}

//赋予按钮权限
function userJurisdiction(obj) {
    if (obj.indexOf(sessionStorage.Jurisdiction)) {
        obj.show();
    } else {
        obj.remove();
    }
}

(function ($) {
    function centerLoader() {

        var winW = $(window).width();
        var winH = $(window).height();

        var spinnerW = $('.fakeloader .fl').outerWidth();
        var spinnerH = $('.fakeloader .fl').outerHeight();
        $('.fakeloader .fl').css({
            'position': 'absolute',
            'left': (winW / 2) - (spinnerW / 2),
            'top': (winH / 2) - (spinnerH / 2),
            'text-align': 'center'
        });
    }

    //<iframe frameborder="0" width="100%" height="100%"></iframe>
    $.fn.fakeLoader = function (options) {
        if (!$('.fakeloader').length) {
            $('body').append('<div class="fakeloader"></div>');
        }
        var settings = $.extend({
            timeToHide: 1200, // Default Time to hide fakeLoader
            pos: 'fixed', // Default Position
            top: '0px', // Default Top value
            left: '0px', // Default Left value
            width: '100%', // Default width
            height: '100%', // Default Height
            zIndex: '999', // Default zIndex
            bgColor: '#2ecc71', // Default background color
            spinner: 'spinner7', // Default Spinner
            imagePath: '' // Default Path custom image
        }, options);
        var spinner01 = '<div class="fl spinner1"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>';
        var spinner02 = '<div class="fl spinner2"><div class="spinner-container container1"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container2"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container3"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div></div>';
        var spinner03 = '<div class="fl spinner3"><div class="dot1"></div><div class="dot2"></div></div>';
        var spinner04 = '<div class="fl spinner4"></div>';
        var spinner05 = '<div class="fl spinner5"><div class="cube1"></div><div class="cube2"></div></div>';
        var spinner06 = '<div class="fl spinner6"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>';
        var spinner07 = '<div class="fl spinner7"><div class="circ1"></div><div class="circ2"></div><div class="circ3"></div><div class="circ4"></div></div>';
        var el = $(this);
        var initStyles = {
            'position': settings.pos,
            'width': settings.width,
            'height': settings.height,
            'top': settings.top,
            'left': settings.left
        };
        el.css(initStyles);
        el.each(function () {
            var a = settings.spinner;
            switch (a) {
                case 'spinner1':
                    el.html(spinner01);
                    break;
                case 'spinner2':
                    el.html(spinner02);
                    break;
                case 'spinner3':
                    el.html(spinner03);
                    break;
                case 'spinner4':
                    el.html(spinner04);
                    break;
                case 'spinner5':
                    el.html(spinner05);
                    break;
                case 'spinner6':
                    el.html(spinner06);
                    break;
                case 'spinner7':
                    el.html(spinner07);
                    break;
                default:
                    el.html(spinner01);
            }
            if (settings.imagePath) {
                el.html('<div class="fl"><img src="' + settings.imagePath + '"></div>');
            }
        });
        centerLoader();
        //debugger

        return this.css({
            'backgroundColor': settings.bgColor,
            'zIndex': settings.zIndex
        });
    }; // End Fake Loader
    $(window).resize(function () {
        centerLoader();
    });

    $.fakeLoadershow = function () {
        $(".fakeloader").show().fakeLoader({
            zIndex: 999, // 默认的zIndex
            spinner: "spinner6", //可选的spinner：'spinner1', 'spinner2', 'spinner3', 'spinner4', 'spinner5', 'spinner6', 'spinner7'
            bgColor: "rgba(0,0,0,0.3)" //全屏遮罩的背景颜色。可以是hex、RGB 或 RGBA 颜色值
        });
    };
    $.fakeLoaderhide = function () {
        $(".fakeloader").fadeOut();
    }
}(jQuery));

//具体描述如下：
//↓↓↓新界面打开时的加载：需要引用fakeLoader.css，同时↓↓↓
//$.fakeLoadershow();  //加载效果显示
//$.fakeLoaderhide();  //加载效果消失

// 定义一个名为 button-counter 的新组件
Vue.component('i-favorite', {
    data: function () {
        return {
            isFavorite: true
        }
    },
    beforeCreate: function () {
    },
    mounted: function () {
        this.isFavorite = leftNavVm.menu.isFavorite;
    },
    updated: function () {
    },
    methods: {
        doFavorite: function () {
            this.isFavorite = !this.isFavorite;
            VanyAjax("/index/favoriteMenu", {
                menuId: leftNavVm.menu.id,
                isFavorite: this.isFavorite
            }, "GET", "body").done(function () {
            });
        }
    },
    template: '<i class="icon-favorite" v-on:click="doFavorite()" v-bind:class="[isFavorite ? \'el-icon-star-on\' : \'el-icon-star-off\']"></i>'
});

Vue.filter("date", function (value) {
    return value.substr(0, 10);
});

function changeLanguage(language) {
    $.get("index", {locale: language}, function (data) {
        history.go(0);
    });
}